<template>
    <rx-dialog @handOk="handleSubmit" @cancel="cancel">
        <rx-layout>
            <div slot="header" style="padding:5px;">
                <a-form layout="inline">
                    <a-row :gutter="24">
                        <a-col :span="9">
                            <a-form-item :label="i18n('chainName','规则别名')">
                                <a-input :placeholder="i18n('chainName','请输入规则别名','input')" v-model="queryParam.Q_CHAIN_NAME__S_LK"/>
                            </a-form-item>
                        </a-col>
                        <a-col :span="9">
                            <a-form-item :label="i18n('chainDesc','规则描述')">
                                <a-input :placeholder="i18n('chainDesc','请输入规则描述','input')" v-model="queryParam.Q_CHAIN_DESC__S_LK"/>
                            </a-form-item>
                        </a-col>
                        <a-col :span="6">
                            <a-button @click="search" icon="search" type="primary">{{$ti18('rxList.searchBtn', '查询')}}</a-button>
                            <a-button style="margin-left: 4px" @click="reset">{{$ti18('rxList.resetBtn','重置')}}</a-button>
                        </a-col>
                    </a-row>
                </a-form>
            </div>
            <div slot="center">
                <rx-grid
                    ref="table"
                    :allowRowSelect="true"
                    :multiSelect="false"
                    :columns="columns"
                    :defaultPageSize="10"
                    url="/api-form/form/core/formLiteFlow/query"
                    :queryParam="queryParam"
                    data-field="result.data"
                    :pageSizeOptions="['10','30','40']"
                    id-field="id"
                    :selectRowKeys="selectRowKeys"
                    @selectChange="onSelectChange"
                >
                </rx-grid>
            </div>
        </rx-layout>
    </rx-dialog>
</template>

<script>
import {Util, RxDialog, RxLayout, BaseList} from "@lowcode/jpaas-common-lib";
import FormLiteFlowApi from '@/api/form/core/formLiteFlow'

export default {
    name: "FormLiteFlowDialog",
    components: {
        RxDialog,
        RxLayout
    },
    mixins: [BaseList],
    props: {
        liteFlowId: {
            type: String,
            default: ""
        },
        layerid: {
            type: String,
            default: ""
        },
        destroy: {
            type: Function
        },
    },
    data() {
        return {
            columns: [
                {
                    title: this.$ti18('rxList.index', '序号'),
                    type: 'indexColumn',
                    width: 50,
                    dataIndex: 'serial',
                    scopedSlots: {customRender: 'serial'}
                },
                {title: this.i18n('chainName','规则别名'), dataIndex: 'chainName', width: 180},
                {title: this.i18n('chainDesc','规则描述'), dataIndex: 'chainDesc', width: 200},
                {title: this.$ti18('rxForm.createTime','创建时间'), dataIndex: 'createTime', width: 150},
            ],
            selectRowKeys: []
        }
    },
    created() {
        this.needFilterAppId("isAppMenu");
        this.queryParam['Q_ENABLED__S_EQ'] = 1;
    },
    mounted() {
        if (this.liteFlowId) {
            this.$refs.table.selectRowKeys = [this.liteFlowId];
        }
    },
    methods: {
        i18n(name,text,key){
            return this.$ti18(name,text,"formLiteFlow",key);
        },
        reset() {
            this.queryParam = {Q_ENABLED__S_EQ: 1};
            let appId=this.curApp.appId;
            if(this.hasAppId && appId){
                this.queryParam.Q_APP_ID__S_EQ=appId;
            }
            this.$nextTick(() => {
                this.$refs.table.loadData();
            })
        },
        getListByParams(parameter) {
            return FormLiteFlowApi.query(parameter)
        },
        handleSubmit(vm) {
            var row = this.$refs.table.getSelectedRow();
            if (!row) {
                this.$message.warn(this.$ti18('rxMsa.masWarn.selectOneRecord', "请选择一行记录"));
                vm.loading = false;
                return;
            }
            Util.closeWindow(this, 'ok', row);
        },
        cancel() {
            Util.closeWindow(this, 'cancel');
        }
    },
    watch: {},
}
</script>

<style scoped>

</style>